/**
 * 
 */
package calculator;

/**
 * @author davide
 *
 */
public class CoordinateManager
{
    public static int relativeCoord(int coord, int zoomFactor)
    {
	return coord * zoomFactor / 100;
    }
    
    public static int absoluteCoord(int coord, int zoomFactor)
    {
	return coord * 100 / zoomFactor;
    }
    
    public static int nearestLesserPowerOfTwo(int value)
    {
	if(value < 2) {
	    return 1;
	}
	
	return new Double(Math.pow(2.0, Math.floor(Math.log10(value) / Math.log10(2.0)))).intValue();
    }
}
